package com.example.demo.Controller;

import com.example.demo.model.BookModel;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/book")
public class BookController {
           @GetMapping ("/getAll")
         public ModelAndView getBookAll(){
               List<BookModel> bookList= new ArrayList<>();
               BookModel book=new BookModel();
               book.setId(1);
               book.setTitle("springboot 企业开发");
               book.setName("宋江");
               book.setCreatdate(new Date());
                 bookList.add(book);

               BookModel book1=new BookModel();
               book1.setId(2);
               book1.setTitle("mysql 企业开发");
               book1.setName("武松");
               book1.setCreatdate(new Date());
                 bookList.add(book1);

               BookModel book2=new BookModel();
               book2.setId(3);
               book2.setTitle("java 企业开发");
               book2.setName("老虎");
               book2.setCreatdate(new Date());
                 bookList.add(book2);

               ModelAndView mv=new ModelAndView();
               mv.addObject("BookList",bookList);
               mv.setViewName("BookList");
                return mv;
             }
}
